package ccnu.agile.config.oss;

import com.aliyun.oss.OSS;
import com.aliyun.oss.OSSClientBuilder;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

/**
 * @Description: OSS相关bean初始化
 * @Author: JreamY
 * @Date: 2021/11/25
 **/
@Component
@ConditionalOnBean(OSSConfig.class)
public class BeanConfig {

    @Bean
    public OSS oss(OSSConfig ossConfig) {
        return new OSSClientBuilder()
                .build(
                        ossConfig.getEndpoint(),
                        ossConfig.getAccessKeyId(),
                        ossConfig.getAccessKeySecret()
                );
    }
}
